<%@ page contentType="text/html;charset=UTF-8" %>
<script>
var touchtime;
$(function(){
	console.log("----")
	getTable();
});
var getTable = ()=>{
	$('#inventoryCheckTable').bootstrapTable({
	    method: 'get',
	    dataType: "json",
	    //显示刷新按钮
	    showRefresh: true,
	    //显示切换手机试图按钮
	    showToggle: true,
	    //显示 内容列下拉框
	    showColumns: true,
	    //显示到处按钮
	    showExport: true,
	    //显示切换分页按钮
	    showPaginationSwitch: true,
	    //最低显示2行
	    minimumCountColumns: 2,
	    striped: true,
	    cache: false,
	    pagination: true,
	    sortOrder: "asc",
	    pageNumber: 1,
	    pageSize: 15,
	    pageList: [15, 50, 100],
	    //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
	    url: "${ctx}/sc/check/findByPage",
	    //查询参数,每次调用是会带上这个参数，可自定义
	    queryParams: function(params) {
	        var searchParam = $("#searchForm").serializeJSON();
	        let date = searchParam.updateDate;
	        
	        searchParam.month = date.substring(0,date.lastIndexOf("-"));
	       console.log(searchParam);
	        searchParam.pageNo = params.limit === undefined ? "1": params.offset / params.limit + 1;
	        searchParam.pageSize = params.limit === undefined ? -1 : params.limit;
	        searchParam.orderBy = params.sort === undefined ? "": params.sort + " " + params.order;
	        return searchParam;
	    },
	    //分页方式：client客户端分页，server服务端分页（*）
	    sidePagination: "server",
	    onClickRow:function(row, $el, $event) {
	    	    if (touchtime == 0) {
	    	        touchtime = new Date().getTime();
	    	    } else {
	    	        if (((new Date().getTime()) - touchtime) < 800) {
	    	            touchtime = 0;
	    	            console.log("---------row.id",row.evidenceId);
	    	            self.location.href="${ctx}/sc/check/detail?evidenceId=" + row.evidenceId+"&type="+row.type;
	    	        } else {
	    	            touchtime = new Date().getTime();
	    	        }
	    	    }
	    },
	    columns: [
	        {
	            field: 'evidenceId',
	            title: 'ID',
	            align:'center',
	            width:'25%'
	        }
	        ,{
	            field: 'typeName',
	            title: '类型',
	            align:'center',
	            width:'25%'
	        },{
	            field: 'createOp',
	            title: '创建人',
	            align:'center',
	            width:'25%'
	        }
	        ,{
	            field: 'createDate',
	            title: '创建时间',
	            align:'center',
	            width:'25%'
	        }
	     ]
	});
}
$(document).ready(function() {

	  if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端

		  $('#inventoryCheckTable').bootstrapTable("toggleView");
		}

	  $('#inventoryCheckTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
                'check-all.bs.table uncheck-all.bs.table', function () {
            $('#remove').prop('disabled', ! $('#inventoryCheckTable').bootstrapTable('getSelections').length);
            $('#edit').prop('disabled', $('#inventoryCheckTable').bootstrapTable('getSelections').length!=1);
        });

//		$("#btnImport").click(function(){
//			jp.open({
//			    type: 1,
//			    area: [500, 300],
//			    title:"导入数据",
//			    content:$("#importBox").html() ,
//			    btn: ['下载模板','确定', '关闭'],
//				    btn1: function(index, layero){
//					  window.location='${ctx}/purchase/purchaseOrder/import/template';
//				  },
//			    btn2: function(index, layero){
//				        var inputForm =top.$("#importForm");
//				        var top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
//				        inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
//				        inputForm.onsubmit = function(){
//				        	jp.loading('  正在导入，请稍等...');
//				        }
//				        inputForm.submit();
//					    jp.close(index);
//				  },
//
//				  btn3: function(index){
//					  jp.close(index);
//	    	       }
//			});
//		});

	  $("#search").click("click", function() {// 绑定查询按扭
		  $('#inventoryCheckTable').bootstrapTable('refresh');
		});

	 $("#reset").click("click", function() {// 绑定查询按扭
		  $("#searchForm  input").val("");
		  $("#searchForm  select").val("");
		  $("#searchForm  .select-item").html("");
		  $('#inventoryCheckTable').bootstrapTable('refresh');
		});

		$('#createDate').datetimepicker({
			 format: "YYYY-MM-DD HH:mm:ss"
		});
		$('#updateDate').datetimepicker({
			 format: "YYYY-MM-DD HH:mm:ss"
		});

	});

  function getIdSelections() {
        return $.map($("#inventoryCheckTable").bootstrapTable('getSelections'), function (row) {
            return row.id
        });
    }


//  function edit(id,e){
//	  e. stopPropagation();
//	  //修改时打开的界面改成非弹出层
//	  window.location = "${ctx}/purchase/purchaseOrder/updatePurchaseOrder?id=" + id;
//  }
//  

</script>